﻿//HTMLInputElement.prototype.value = function () {
//    return "testing";
//}
//function extend(subClass, baseClass) {
//    for (var ptototypeName in baseClass.prototype) {
//        if (typeof (subClass.prototype[ptototypeName]) == 'undefined') {
//            subClass.prototype[ptototypeName] = baseClass.prototype[ptototypeName];
//        }
//    }
//    subClass.prototype.constructor = subClass;
//}

//var HTMLInputElementWithThousandSeperator = function () {
//    HTMLInputElement.call(this);
//    this.value = "Alert....";
//};

//HTMLInputElementWithThousandSeperator.prototype = { };

//extend(HTMLInputElementWithThousandSeperator, HTMLInputElement);

//var originalGetElementById = document.getElementById;

//document.getElementById = function (id) {
//    var element = originalGetElementById(id);
//    return element;
//}

function cloneObject(object) {
    var newObj = new Object();

    for (var attribute in object) {
        if (typeof (object[attribute]) == "object") {
            if (object[attribute].length != null & object[attribute].length != undefined) {
                //newObj[attribute] = cloneArray(object[attribute]);
            }
            else {
                newObj[attribute] = cloneObject(object[attribute]);
            }
        }
        else {
            newObj[attribute] = object[attribute];
        }
    }

    return newObj;
}

function cloneArray(object) {
    var newArray = new Array();

    for (var i = 0; i < object.length; i++) {
        if (typeof (object[i]) == "object") {
            if (object[i].length != undefined) {
                newArray[i] = cloneArray(object[i]);
            }
            else {
                newArray[i] = cloneObject(object[i]);
            }
        }
        else {
            newArray[i] = object[i];
        }
    }
    return newArray;
}

function onButtonClick() {
    var element = document.getElementById("TextBox");

    element.attachEvent("onpropertychange", function () { alert("Property Changed."); });
//    var newElement = { };
//    $.extend(element, newElement);
//    

//    newElement.value = "Testing";

//    alert(newElement.value);
}